package com.start.avue.mapper;

import com.alibaba.fastjson2.JSONArray;
import com.start.avue.tools.AvueTools;

public class AvueMapMapper extends AvueDefaultMapper {
    public static final String MAPPER_TYPE = "map";
    public static final String MAPPER_TYPE_2 = "avue-input-map";
    @Override
    public Object labelToValue(String label) {
        return super.labelToValue(label);
    }

    @Override
    public Object valueToLabel(Object value) {
        if (value == null) return "";
        String valStr = String.valueOf(value);
        if (!AvueTools.strIsJson(valStr)) {
            return String.valueOf(value);
        }
        JSONArray array = JSONArray.parseArray(valStr);
        valStr = array.getString(array.size() - 1);
        return valStr;
    }
}
